﻿using Renci.iRods.Common;

namespace Renci.iRods.Packets
{
    [PacketAttribute("Version_PI")]
    internal class VersionPacket : Packet
    {
        //internal const string NAME = "Version_PI";

        /// <summary>
        /// Gets or sets the status. If status is more then zero then <see cref="ReconnectPort"/> and <see cref="ReconnectAddress"/> are specified.
        /// </summary>
        /// <value>
        /// The status.
        /// </value>
        [PacketField("status", 0, DataTypes.Int)]
        public int Status { get; set; }

        [PacketField("relVersion", 1, DataTypes.String, 64)]
        public string RelVersion { get; set; }

        [PacketField("apiVersion", 2, DataTypes.String, 64)]
        public string ApiVersion { get; set; }

        [PacketField("reconnPort",3, DataTypes.Int)]
        public int ReconnectPort { get; set; }

        [PacketField("reconnAddr", 4, DataTypes.String, 256)]
        public string ReconnectAddress { get; set; }

        [PacketField("cookie",5, DataTypes.Int)]
        public int Cookie { get; set; }
        
        //public override byte[] PackAsBinary()
        //{
        //    throw new NotImplementedException();
        //}

        //public override byte[] PackAsXml()
        //{
        //    throw new NotImplementedException();
        //}

        //public override void Unpack(byte[] data)
        //{
        //    throw new NotImplementedException();
        //}

        //public override void Unpack(XElement xml)
        //{
        //    if (!xml.Name.LocalName.Equals(VersionPacket.NAME))
        //        throw new InvalidOperationException(string.Format("'{0}' is expected", VersionPacket.NAME));

        //    this.Status = int.Parse(xml.Element("status").Value);
        //    this.RelVersion = xml.Element("relVersion").Value;
        //    this.ApiVersion = xml.Element("apiVersion").Value;
        //    this.ReconnectPort = int.Parse(xml.Element("reconnPort").Value);
        //    this.ReconnectAddress = xml.Element("reconnAddr").Value;
        //    this.Cookie = int.Parse(xml.Element("cookie").Value);
        //}
    }
}
